<?php
/**
 * Nhung ham dùng để hỗ trợ các helper khác
 * */

class OthersHelper extends AppHelper {
   var $helpers = array('Html');
   /**
    * rankvalue dung de xep hang "k" trong mang $mang
    * 
    * @param    $k      Gia tri can xep hang
    * @param    $mang   Mang chua gia tri can xep hang
    * 
    * @return           Tra ve thu hang cua phan tu "k" trong mang chay tu i den j
    * */ 
   function rank_value($k, $mang=array()){
        rsort($mang); 
        return array_search($k,$mang)+1;
   }   
    /**
    * conghoa dung de xuat dong chu "cong hoa  xa hoi chu nghia" co ten don vi
    * 
    * @param    $dvcha      Se hien o phan ben trai, phia tren
    * @param    $dvcon      Hien phan ben trai, phia duoi
    * @param    $socotrai      Phan ben trai se merge bao nhieu cot
    * @param    $socotphai     Phan ben phai se merge bao nhieu cot
    
    * 
    * @return           HTML
    * */ 
  function conghoa($dvcha,$dvcon,$socottrai,$socotphai,$tieude=null){
        $kq='<table><tr><td colspan="'.$socottrai.'" align="center" style="font-weight: bold; ">';
        $kq.=$dvcha;
        $kq.='</td>
            <td colspan="'.$socotphai.'" align="center" style="font-weight: bold; ">
            CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM</td>
            </tr>
            <tr>
            <td colspan="'.$socottrai.'" align="center" style="font-weight: bold; ">';
        $kq.=$dvcon;
        $kq.='</td><td colspan="'.$socotphai.'" align="center" style="font-weight: bold; ">
            Độc lập- tự do- hạnh phúc</td>
            </tr>';
        
        if(!empty($tieude)){   
            $kq.='<tr>
                <td colspan="'.($socottrai+$socotphai).'" align="center" style="font-weight: bold; font-size: large;">';
        
            $kq.=$tieude;
            $kq.='</td></tr>';
        }
            
        $kq.='</table>';
        
        return $kq;
  }
  
}
 ?>